//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.pentaho.di.ui.trans.steps.shentong.oss.client;

import java.io.InputStream;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;

public class XmlHandler implements HttpResultHandler {
    private Unmarshaller unmarshaller;

    public XmlHandler() {
        try {
            JAXBContext jaxbContext = JAXBContext.newInstance(new Class[]{OssError.class});
            this.unmarshaller = jaxbContext.createUnmarshaller();
        } catch (Exception e) {
        	e.printStackTrace();
//            Trace.error(Menu.DOC_MANAGE, "OSS解析初始化失败", (String)null, (String)null, var2);
        }

    }

    public AbstractXMLData handleResponse(InputStream inputStream) {
        try {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setExpandEntityReferences(false);
            dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
            dbf.setFeature("http://javax.xml.XMLConstants/feature/secure-processing", true);
            dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
            dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
            dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
            dbf.setXIncludeAware(false);
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document document = db.parse(inputStream);
            return (AbstractXMLData)this.unmarshaller.unmarshal(document);
        } catch (Exception e) {
        	e.printStackTrace();
//            Trace.error(Menu.DOC_MANAGE, "OSS解析失败", (String)null, (String)null, var5);
            return null;
        }
    }
}
